package com.ocom.mqsimple.controller;


import com.alibaba.fastjson.JSON;
import com.ocom.common.constant.MqSimpleApiUrl;
import com.ocom.common.enums.ResultEnum;
import com.ocom.common.request.wx.UserAccessPageSetAccessRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.mqsimple.business.access.AccessProductService;
import com.ocom.mqsimple.business.account.AccountProductService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@Slf4j
@RestController
public class AddXFAccountMqController {
    private Logger logger = LoggerFactory.getLogger(AddXFAccountMqController.class);


    @Autowired
    private AccountProductService accountProductService;

    // 初始化账号(addXFAccount)
    @PostMapping(MqSimpleApiUrl.URL_AddXFAccount)
    public Result AddXFAccount(@RequestBody Map<String,Object> map){
        log.info("初始化账号(addXFAccount) 请求参数：{{}}",map);
        try {
            accountProductService.mqAddAccount(JSON.toJSONString(map));
        }catch (Exception e){
            log.error("发送mq失败错误【{}】",e.getMessage());
            return ResultUtil.error(ResultEnum.Err_4006);
        }
        return ResultUtil.success();
    }
}
